package com.junzhiit.nengji.cms.web.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.bainaeco.framework.util.AssertUtil;
import com.junzhiit.nengji.cms.service.RechargeRecordService;
import com.junzhiit.nengji.cms.web.vo.DataTablesParamVO;
import com.junzhiit.nengji.cms.web.vo.RechargeRecordVO;
import com.junzhiit.nengji.cms.web.vo.ResultVO;

import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/recharge/record")
public class RechargeRecordController extends BaseController{
	
	@Autowired
	private RechargeRecordService rechargeRecordService;
	
	@ApiOperation(value = "添加一个充值赠送流水记录")
	@RequestMapping(method = RequestMethod.POST)
	public ResultVO add(RechargeRecordVO vo){
		AssertUtil.notBlank(vo.getUserId(), "userId is required.");
		AssertUtil.notNull(vo.getPayWay(),"payWay is required.");
		AssertUtil.notNull(vo.getRechargeMoney(), "rechargeMoney is required.");
		AssertUtil.notNull(vo.getGiveType(), "giveType is required.");
		AssertUtil.notNull(vo.getGiveValue(), "giveValue is required.");
		return rechargeRecordService.add(vo);
	}
	
	@ApiOperation(value = "获取所有充值流水列表")
	@RequestMapping(value="/all",method = RequestMethod.GET)
	public Map<String, Object> findAll(RechargeRecordVO vo,DataTablesParamVO dtp){
		AssertUtil.notNull(dtp.getStart(), "start is required.");
		AssertUtil.notNull(dtp.getLength(), "length is required.");
		return rechargeRecordService.findAll(vo, dtp);
	}
	
}
